package net.tw.transactional2.task.impl;

import net.tw.transactional2.task.TaskCService;
import org.springframework.stereotype.Service;

@Service
public class TaskCServiceImpl implements TaskCService {
    @Override
    public void syncTaskC(Long threadId) {
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        Thread[] threads = new Thread[threadGroup.activeCount()];
        threadGroup.enumerate(threads);
        for (Thread thread : threads) {
            if (thread.getId() == threadId) {
                synchronized (thread) {
                    thread.notify();
                }
                break;
            }
        }
    }
}
